<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="./node_modules/handsontable/dist/handsontable.full.js"></script>
    <link rel="stylesheet" href="./node_modules/handsontable/dist/handsontable.css">
</head>
<body>
<button id="btn_click_add"> click me to add</button>
<button id="btn_click_del"> click me to del</button>

<div id="example1"></div>

<div id="example2"></div>
</body>
<script type="text/javascript">
    var
            objectData = [
                {id: 1, name: 'Ted Right', address: '',other:''},
                {id: 2, name: 'Frank Honest', address: ''},
                {id: 3, name: 'Joan Well', address: ''},
                {id: 4, name: 'Gail Polite', address: ''},
                {id: 5, name: 'Michael Fair', address: ''},
            ],
            container3 = document.getElementById('example2'),
            hot3;

    hot3 = new Handsontable(container3, {
        data: objectData,
        colHeaders: true,
        minSpareRows: 1,
//        contextMenu: true,
        allowEmpty:false
    });

    var data = [
                ['', 'Kia', 'Nissan', 'Toyota', 'Honda', 'Mazda', 'Ford'],
//                ['2012', 10, 11, 12, 13, 15, 16],
//                ['2013', 10, 11, 12, 13, 15, 16],
//                ['2014', 10, 11, 12, 13, 15, 16],
//                ['2015', 10, 11, 12, 13, 15, 16],
//                ['2016', 10, 11, 12, 13, 15, 16]
            ],
            container1 = document.getElementById('example1'),
            hot1;

    hot1 = new Handsontable(container1, {
        data: data,
        startRows: 5,
        startCols: 5,
        colHeaders: true,
//        minSpareRows: 1,//最少的空数据
//        columns: [
//            {data: 0},
//            {data: 2},
//            {data: 3},
//            {data: 4},
//            {data: 5},
//            {data: 6}
//        ],
//        contextMenu:true
    });
    btn_click_add = document.getElementById('btn_click_add')
    btn_click_add.addEventListener("click",function (event) {
        console.log(event);
        console.log(hot1.countRows());
        hot1.alter('insert_row', null)
    });
    btn_click_del = document.getElementById('btn_click_del')
    btn_click_del.addEventListener("click",function (event) {
        console.log(event);
        console.log(hot1.countRows());
        if(hot1.countRows() == 1){

        }else {
            hot1.alter('remove_row', null)
        }
    })
</script>
</html>